
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    if(argc<2)
        printf("need a parameter for output file.\n");
    else
    {
        FILE * fo=fopen(argv[1],"w");

        fputs("\nPublic Module buildInfo\n",fo);

        fputs("    Public Const buildtime As String = \"",fo);
        time_t t=time(NULL);
        tm *lt=localtime(&t);
        fprintf(fo,"%04d-%02d-%02d_%02d:%02d\"\n",lt->tm_year+1900,lt->tm_mon+1,lt->tm_mday,lt->tm_hour,lt->tm_min);

        fputs("    Public Const buildmachine As String = \"",fo);
        fputs(getenv("COMPUTERNAME"),fo);
        fputs("\"\n",fo);

        fputs("    Public Const builduser As String = \"",fo);
        fputs(getenv("USERDOMAIN"),fo);
        fputs("\\",fo);
        fputs(getenv("USERNAME"),fo);
        fputs("\"\n",fo);

        fputs("    Public Const buildsysver As String = \"",fo);
        if(getenv("VER")==NULL)
        {
            fputs("HAVE_NOT_GET_VER",fo);
        }
        else
        {
            fputs(getenv("VER"),fo);
        }
        fputs("\"\n",fo);

        fputs("    Public Const buildprocessor As String = \"",fo);
        fputs(getenv("PROCESSOR_ARCHITECTURE"),fo);
        fputs("\"\n",fo);

        fputs("End Module\n",fo);

        fclose(fo);
        delete fo;
    }

    return 0;
}
